package com.fac.controller.admin;

import com.fac.dto.RepairOrderAssignDTO;
import com.fac.dto.RepairOrderPageQueryDTO;
import com.fac.dto.RepairOrderProgressDTO;
import com.fac.result.PageResult;
import com.fac.result.Result;
import com.fac.service.RepairOrderService;
import com.fac.vo.RepairOrderAssignVO;
import com.fac.vo.RepairOrderProgressVO;
import com.fac.vo.RepairOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 管理端维修订单Controller
 */
@RestController("adminRepairOrderController")
@RequestMapping("/admin/repairOrders")
@Api(tags = "管理端-维修订单接口")
@Slf4j
public class RepairOrderController {

    @Autowired
    private RepairOrderService repairOrderService;

    /**
     * 维修单列表查询
     */
    @GetMapping
    @ApiOperation("维修单列表查询")
    public Result<PageResult> page(RepairOrderPageQueryDTO queryDTO) {
        log.info("维修单列表查询：{}", queryDTO);
        PageResult pageResult = repairOrderService.pageQuery(queryDTO);
        return Result.success(pageResult);
    }

    /**
     * 分配维修工
     */
    @PutMapping("/{orderId}/assign")
    @ApiOperation("分配维修工")
    public Result<RepairOrderAssignVO> assign(
            @PathVariable Long orderId,
            @RequestBody RepairOrderAssignDTO assignDTO) {
        log.info("分配维修工，订单ID：{}，分配信息：{}", orderId, assignDTO);
        RepairOrderAssignVO vo = repairOrderService.assign(orderId, assignDTO);
        return Result.success(vo);
    }

    /**
     * 更新维修进度
     */
    @PutMapping("/{orderId}/progress")
    @ApiOperation("更新维修进度")
    public Result<RepairOrderProgressVO> updateProgress(
            @PathVariable Long orderId,
            @RequestBody RepairOrderProgressDTO progressDTO) {
        log.info("更新维修进度，订单ID：{}，进度信息：{}", orderId, progressDTO);
        RepairOrderProgressVO vo = repairOrderService.updateProgress(orderId, progressDTO);
        return Result.success(vo);
    }
} 